package com.qd.panda.service.stroke;

/**
 * @author sjk
 */
public class DisplayUtil {
    /**
     * 生成订单未入场
     */
    public static final int PROCESS_STATUS_0 = 0;
    /**
     * 预约主动取消
     */
    public static final int PROCESS_STATUS_1 = 1;
    /**
     * 预约超时取消
     */
    public static final int PROCESS_STATUS_2 = 2;
    /**
     * 已入场
     */
    public static final int PROCESS_STATUS_3 = 3;
    /**
     * 已缴费未出场
     */
    public static final int PROCESS_STATUS_4 = 4;
    /**
     * 已出场
     */
    public static final int PROCESS_STATUS_5 = 5;
    /**
     * 保安取消
     */
    public static final int PROCESS_STATUS_6 = 6;
    /**
     * 已扫码未入场
     */
    public static final int PROCESS_STATUS_7 = 7;
    /**
     * 开始
     */
    public static final int TRIP_STATUS_1 = 1;
    /**
     * 结束
     */
    public static final int TRIP_STATUS_2 = 2;
    /**
     * 未支付
     */
    public static final int PAY_STATUS_0 = 0;
    /**
     * 支付成功
     */
    public static final int PAY_STATUS_1 = 1;
    /**
     * 支付失败
     */
    public static final int PAY_STATUS_2 = 2;
    /**
     * 已支付
     */
    public static final int PAY_STATUS_3 = 3;
    /**
     * 取消支付
     */
    public static final int PAY_STATUS_4 = 4;
    /**
     * 申请退款
     */
    public static final int PAY_STATUS_7 = 7;
    /**
     * 退款成功
     */
    public static final int PAY_STATUS_8 = 8;
    /**
     * 退款失败
     */
    public static final int PAY_STATUS_9 = 9;
    /**
     * 预约订单
     */
    public static final int ORDER_TYPE_0 = 0;
    /**
     * 停车缴费订单
     */
    public static final int ORDER_TYPE_1 = 1;
    /**
     * 超时补缴费订单
     */
    public static final int ORDER_TYPE_2 = 2;
    /**
     * 充电订单
     */
    public static final int ORDER_TYPE_3 = 3;
    /**
     * 加油
     */
    public static final int ORDER_TYPE_4 = 4;
    /**
     * 商城购物
     */
    public static final int ORDER_TYPE_5 = 5;
    /**
     * 短期车位租赁
     */
    public static final int ORDER_TYPE_6 = 6;
    /**
     * 停车(海康)
     */
    public static final int ORDER_TYPE_7 = 7;
    /**
     * 钱包充值
     */
    public static final int ORDER_TYPE_8 = 8;
    /**
     * 0申请退款
     */
    public static final int REFUND_STATUS_0 = 0;
    /**
     * 1退款成功
     */
    public static final int REFUND_STATUS_1 = 1;
    /**
     * 2退款失败
     */
    public static final int REFUND_STATUS_2 = 2;
    /**
     * 0停车
     */
    public static final int TRIP_TYPE_0 = 0;
    /**
     * 1充电
     */
    public static final int TRIP_TYPE_1 = 1;
    /**
     * 2加油
     */
    public static final int TRIP_TYPE_2 = 2;
    /**
     * 3短期租赁
     */
    public static final int TRIP_TYPE_3 = 3;
    /**
     * 4商城
     */
    public static final int TRIP_TYPE_4 = 4;
    /**
     * 充电状态,-1：等待确认
     */
    public static final int CHARGE_STAT_0 = -1;
    /**
     * 充电状态,1：启动中
     */
    public static final int CHARGE_STAT_1 = 1;
    /**
     * 充电状态,2：充电中
     */
    public static final int CHARGE_STAT_2 = 2;
    /**
     * 充电状态,3：停止中
     */
    public static final int CHARGE_STAT_3 = 3;
    /**
     * 充电状态,4：已结束
     */
    public static final int CHARGE_STAT_4 = 4;
    /**
     * 充电状态,5：未知
     */
    public static final int CHARGE_STAT_5 = 5;

    private DisplayUtil() {

    }

    protected static String getProcessStatusDisplay(Integer processStatus) {
        String display = "";
        if (null == processStatus) {
            return display;
        }
        switch (processStatus) {
            case 0:
                display = "生成订单未入场";
                break;
            case 1:
                display = "预约主动取消";
                break;
            case 2:
                display = "预约超时取消";
                break;
            case 3:
                display = "已入场";
                break;
            case 4:
                display = "已缴费未出场";
                break;
            case 5:
                display = "已出场";
                break;
            case 6:
                display = "保安取消";
                break;
            case 7:
                display = "已扫码未入场";
                break;
            default:
                break;
        }
        return display;
    }

    protected static String getTripStatusDisplay(Integer tripStatus) {
        String display = "";
        if (null == tripStatus) {
            return display;
        }
        if (tripStatus == TRIP_STATUS_1) {
            display = "开始";
        }
        if (tripStatus == TRIP_STATUS_2) {
            display = "结束";
        }
        return display;
    }

    public static String getTripTypeDisplay(Integer tripType) {
        String display = "";
        if (null == tripType) {
            return display;
        }
        if (tripType == TRIP_TYPE_0) {
            display = "停车";
        }
        if (tripType == TRIP_TYPE_1) {
            display = "充电";
        }
        if (tripType == TRIP_TYPE_2) {
            display = "加油";
        }
        if (tripType == TRIP_TYPE_3) {
            display = "短期租赁";
        }
        if (tripType == TRIP_TYPE_4) {
            display = "商城";
        }
        return display;
    }

    public static String getOrderTypeDisplay(Integer orderType) {
        String display = "";
        if (null == orderType) {
            return display;
        }
        switch (orderType) {
            case ORDER_TYPE_0:
                display = "预约订单";
                break;
            case ORDER_TYPE_1:
                display = "停车缴费订单";
                break;
            case ORDER_TYPE_2:
                display = "超时补缴费订单";
                break;
            case ORDER_TYPE_3:
                display = "充电订单";
                break;
            case ORDER_TYPE_4:
                display = "加油订单";
                break;
            case ORDER_TYPE_5:
                display = "商城订单";
                break;
            default:
                break;
        }
        return display;
    }

    public static String getPayStatusDisplay(Integer payStatus) {
        String display = "";
        if (null == payStatus) {
            return display;
        }
        switch (payStatus) {
            case PAY_STATUS_0:
                display = "未支付";
                break;
            case PAY_STATUS_1:
                display = "支付成功";
                break;
            case PAY_STATUS_2:
                display = "支付失败";
                break;
            case PAY_STATUS_3:
                display = "已支付";
                break;
            case PAY_STATUS_4:
                display = "取消支付";
                break;
            default:
                break;
        }
        return display;
    }

    public static String getRefundStatusDisplay(Integer refundStatus) {
        String display = "";
        if (null == refundStatus) {
            return display;
        }
        switch (refundStatus) {
            case REFUND_STATUS_0:
                display = "申请退款";
                break;
            case REFUND_STATUS_1:
                display = "退款成功";
                break;
            case REFUND_STATUS_2:
                display = "退款失败";
                break;
            default:
                break;
        }
        return display;
    }

    public static String getChargeStatDisplay(Integer chargeStat) {
        String display = "";
        if (null == chargeStat) {
            return display;
        }
        switch (chargeStat) {
            case CHARGE_STAT_1:
                display = "启动中";
                break;
            case CHARGE_STAT_0:
                display = "等待确认";
                break;
            case CHARGE_STAT_2:
                display = "充电中";
                break;
            case CHARGE_STAT_3:
                display = "停止中";
                break;
            case CHARGE_STAT_4:
                display = "已结束";
                break;
            case CHARGE_STAT_5:
                display = "位置";
                break;
            default:
                break;
        }
        return display;
    }

    /**
     * 格式化停车时长，传入参数为秒，格式化以后为“几天较小时几分"
     *
     * @param parkTime 停车时长，单位是秒
     * @return 停车时长显示
     */
    protected static String displayParkTime(Long parkTime) {
        return durationConvert(parkTime);
    }

    private static String durationConvert(Long dateTime) {
        if (dateTime > 60) {
            if (dateTime > 3600) {
                if (dateTime > 86400) {
                    return dateTime / 86400 + "天" + durationConvert(dateTime % 86400);
                } else {
                    return dateTime / 3600 + "时" + durationConvert(dateTime % 3600);
                }
            } else {
                return dateTime / 60 + "分" + durationConvert(dateTime % 60);
            }
        } else {
            return dateTime + "秒";
        }
    }
}
